package com.yserp.project.erp.bill.payment.controller;

import com.yserp.framework.web.controller.BaseController;
import com.yserp.framework.web.domain.AjaxResult;
import com.yserp.framework.web.page.TableDataInfo;
import com.yserp.project.erp.bill.payment.domain.PaymentItem;
import com.yserp.project.erp.bill.payment.service.IPaymentItemService;
import com.yserp.project.erp.order.purchorder.domain.PurchOrder;
import com.yserp.project.erp.order.purchorder.service.IPurchOrderService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 商品入库单子Controller
 * 
 * @author yserp
 * @date 2022-08-08
 */
@Controller
@RequestMapping("/bill/payment/item")
public class PaymentItemController extends BaseController
{
    private String prefix = "erp/bill/payment";

    @Autowired
    private IPaymentItemService paymentItemService;
    @Autowired
    private IPurchOrderService purchOrderService;

    @RequiresPermissions("bill:payment:view")
    @GetMapping()
    public String payment()
    {
        return prefix + "/payment";
    }

    /**
     * 查询商品入库单子列表
     */
    @RequiresPermissions("bill:payment:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaymentItem paymentItem)
    {
        startPage();
        List<PaymentItem> list = paymentItemService.selectPaymentItemList(paymentItem);
        return getDataTable(list);
    }

    /**
     * 根据供应商获取预付订单列表
     */
    @PostMapping("/selectPurchOrderAjaxList")
    @ResponseBody
    public AjaxResult getPurchOrderList(PurchOrder purchOrder) {
        List<PaymentItem> mapList = purchOrderService.selectPurchOrderListBySupplierId(purchOrder.getSupplierId());
        return AjaxResult.success(mapList);
    }
}
